<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Init</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

    <script>

        $(document).ready(function() {

            $("#login-button").click(function(event) {
                email = $("#email").val();
                console.log("submitting " + email);
                event.preventDefault();
                //var data = {imie: email};
                //console.log(data);

                $.ajax({
                    type: 'POST',
                    dataType: 'json',
                    url: '/user/register',
                    data: {email : "xxx@xxx.com", password : "123456"},
                    beforeSend: function(){console.log("sending: " + this.data);},
                    success: function(msg) {
                        console.log("success handler");
                        console.log(msg);
                        alert(msg);
                    },
                    error:function (xhr, ajaxOptions, thrownError){
                        console.log(xhr.status);
                        console.log(thrownError);
                    }
                });
            });


        });
    </script>
</head>
<body>


<input type="text" id="email" value="some@data.xxx"></input>

<input type="submit" value="Send me your name!" id="login-button">

</body>
</html>